<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <div th:replace="~{common/common-head.html::common-head}"></div>
</head>
<body class="body-common">
<div class="page-container">
    <form class="layui-form layui-form-pane" action="">
                <div class="layui-form-item">
                    <label class="layui-form-label">旧密码</label>
                    <div class="layui-input-block">
                        <input type="password" name="password" id="password" maxlength="32" lay-verify="required" autocomplete="new-password"
                               placeholder="请输入旧密码" class="layui-input" >
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">新密码</label>
                    <div class="layui-input-block">
                        <input type="password" name="newPassword" id="newPassword" maxlength="32"  lay-verify="required" autocomplete="new-password"
                               placeholder="请输入新密码" class="layui-input"  >
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">请再次输入</label>
                    <div class="layui-input-block">
                        <input type="password" name="newPassword1" id="newPassword1" maxlength="32" lay-verify="required" autocomplete="new-password"
                               placeholder="请再次输入新密码" class="layui-input"  >
                    </div>
                </div>
        <div class="layui-form-item" style="text-align: center">
            <input type="button" class="layui-btn" lay-submit="" lay-filter="save-data" value="修改" />
            <input type="button" class="layui-btn"  value="关闭" onclick="closeI()" />
        </div>
    </form>
</div>
<!--
<script src="//res.layui.com/layui/dist/layui.js" charset="utf-8"></script>-->
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form
                , layer = layui.layer
                , layedit = layui.layedit
                , laydate = layui.laydate;
        form.render();


           laydate.render({
               elem: '#createTime'
               , type: 'datetime'
           });
           laydate.render({
               elem: '#updateTime'
               , type: 'datetime'
           });

        //自定义验证规则
        form.verify({});

        //监听提交
        form.on('submit(save-data)', function (data) {
            if($("#newPassword").val()!=$("#newPassword1").val()){
                myAlert("两次密码必须相同");
                return;
            }
            $.post(rootPath+"sysUser/changePassword",data.field,function (data) {
                if(data.code==0){
                    myAlert("修改成功");
                    setTimeout(function () {
                        closeI()
                    },alertTime)
                }else{
                    myAlert("修改失败->"+data.message)
                }
            });
            return false
        });

    });

    function closeI() {
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭
    }
</script>

</body>
</html>